package typechecker;

import java.util.HashMap;
import java.util.Map;

import typechecker.ast.term.TermVariable;
import typechecker.ast.type.TypeExpression;

public class TypingContext extends HashMap<TermVariable, TypeExpression >{
	private static final long serialVersionUID = 2676760288845391514L;	
	@Override
	public TypeExpression get(Object key) {
		TypeExpression te = super.get(key);
		if(te == null)
			throw new TypeCheckingException("Free variable in typing context : " + key);
		return te;
	}
	
	@Override
	public String toString() {
		String ret ="";
		for(Map.Entry<TermVariable, TypeExpression > kv : this.entrySet()){
			ret += (kv.getKey().preetyPrint() + " <-> " + kv.getValue().preetyPrint() + "\n");
		}
		return ret;
	}
}
